<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2018/12/14
 * Time: 16:13
 */
namespace common\sources\write\auditclassify;

use common\models\craftsman\AuditClassify;
use Yii;

class AuditClassifyAccess implements IAuditClassifyAccess
{
    public function addClassify($name,$pid)
    {
        $res = Yii::$app->db->createCommand()->insert('audit_classify', [
            'name' => $name,
            'pid' => $pid,
            'create_time' => time()
        ])->execute();
        return $res;
    }
    //修改分类
    public function modifyClassify($data)
    {
        $sql = 'UPDATE ' . AuditClassify::tableName() . ' SET name = :name,update_time = :update_time,pid = :pid WHERE id = :id ';
        return Yii::$app->db->createCommand($sql)
            ->bindValues([
                ':name' => $data['name'],
                ':pid' => $data['pid'],
                ':update_time' => time(),
                ':id' => $data['a_id']
            ])->execute();
    }
    //删除分类
    public function delClassify($data)
    {
        return Yii::$app->db->createCommand()->delete(AuditClassify::tableName(), 'id = '.$data['a_id'])->execute();
    }

}